import random
money = 5000
a = random.randint(0, 999)
for i in range(999):
    n = int(input("请输入您想猜的数字:"))
    if n == a:
        print("恭喜猜中,本轮幸运数字:"+str(a))
        money += 3000
        for j in range(999):
            k = (input("您是否想要进行下局游戏,如果想要请输入1:"))
            if k == "1":
                a = random.randint(0, 999)
            else:
                break
            break
    elif n < a:
        print("抱歉,您猜的数字小了:")
        money -= 500
        break
    elif n > a:
        print("抱歉,您猜的数字大了:")
        money -= 500
        break
    if money < 500:
        print("抱歉,您的余额不足,游戏退出!")
        break

